cmake_minimum_required(VERSION 3.0)

project(livox_sdk)

set(SDK_LIBRARY ${PROJECT_NAME}_common_static)
add_library(${SDK_LIBRARY} STATIC "")

set(LIVOX_SDK_COMMON_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "")

target_include_directories(${SDK_LIBRARY}
        PUBLIC
        include
	include/third_party/FastCRC
        include/third_party/spdlog
        PRIVATE
        src)

set_target_properties(${SDK_LIBRARY} PROPERTIES PUBLIC_HEADER "include/livox_sdk_common.h;include/livox_def_common.h;include/livox_sdk_common_util.h")

target_compile_options(${SDK_LIBRARY}
        PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall -Werror -Wno-c++11-long-long>
        PRIVATE $<$<CXX_COMPILER_ID:AppleClang>:-Wno-unknown-pragmas -Wall -Werror -Wno-c++11-long-long>
        PRIVATE $<$<CXX_COMPILER_ID:Clang>:-Wno-unknown-pragmas -Wall -Werror -Wno-c++11-long-long>)

target_sources(${SDK_LIBRARY}
        PRIVATE
        src/livox_sdk_common.cpp
        src/lvx_handler/lvx_file_record_handler.h
        src/lvx_handler/lvx_file_record_handler.cpp
        src/lvx_handler/lvx_file_parse_handler.h
        src/lvx_handler/lvx_file_parse_handler.cpp
        src/lvx_handler/lvx_file_converter.h
        src/lvx_handler/lvx_file_converter.cpp
        src/lvx_handler/lvx_file_def.h
        src/lvx_handler/lvx_file_manager.h
        src/lvx_handler/lvx_file_manager.cpp
        src/converter/lvx_to_point_cloud_frame.h
        src/converter/lvx_to_point_cloud_frame.cpp

        src/upgrader/upgrade_manager.h
        src/upgrader/upgrade_manager.cpp
        src/upgrader/firmware/firmware.h
        src/upgrader/firmware/firmware.cpp


        src/upgrader/vehicle/vehicle_upgrader.h
        src/upgrader/vehicle/vehicle_upgrader.cpp
        src/upgrader/vehicle/vehicle_lidar_upgrader.h
        src/upgrader/vehicle/vehicle_lidar_upgrader.cpp

        src/upgrader/livox_lidar/livox_lidar_upgrader.h
        src/upgrader/livox_lidar/livox_lidar_upgrader.cpp

        src/upgrader/industry/industry_upgrader.h
        src/upgrader/industry/industry_upgrader.cpp

        src/pub_handler/pub_handler.h
        src/pub_handler/pub_handler.cpp
        src/pub_handler/lidar_pub_handler.h
        src/pub_handler/lidar_pub_handler.cpp

        src/algorithm/obstacle_zone_converter/obstacle_zone_converter.h
        src/algorithm/obstacle_zone_converter/obstacle_zone_converter.cpp)

set(Eigen3_DIR src/third_party/eigen/share/eigen3/cmake)
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})


target_link_libraries(${SDK_LIBRARY}
        PUBLIC
        ${PROJECT_NAME}_static
        ${PROJECT_NAME}_vehicle_static
        livox_lidar_sdk_static
)

install(TARGETS ${SDK_LIBRARY}
        PUBLIC_HEADER DESTINATION include
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib)

